//
//  XCHotListCollectionViewCell.m
//  SoundOfNature
//
//  Created by 梁新昌 on 16/3/8.
//  Copyright © 2016年 梁新昌. All rights reserved.
//

#import "XCHotListCollectionViewCell.h"
#import "UIImageView+WebCache.h"
@implementation XCHotListCollectionViewCell

- (void)dealloc {
    [_picUrlImageView release];
    [_listenCountLable release];
    [_SONLabel release];
    [_descLable release];
    [_listenButton release];
    [_secModel release];
    [super dealloc];
}
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {

        self.picUrlImageView = [[UIImageView alloc] initWithFrame:CGRectZero];
        self.picUrlImageView.userInteractionEnabled = YES;
        self.listenCountLable = [[UILabel alloc] initWithFrame:CGRectZero];
        self.listenCountLable.font = [UIFont systemFontOfSize:8];
        self.listenCountLable.userInteractionEnabled = YES;
        self.SONLabel = [[XCBaseLable alloc] initWithFrame:CGRectZero];
//        self.SONLabel.text = @"天籁之音";
        self.SONLabel.font = [UIFont systemFontOfSize:8];
        self.SONLabel.userInteractionEnabled = YES;
        self.listenButton = [UIButton buttonWithType:UIButtonTypeSystem];
        
        
        self.descLable = [[XCBaseLable alloc] initWithFrame:CGRectZero];
        self.descLable.font = [UIFont systemFontOfSize:13];
        self.descLable.numberOfLines = 2;
        
        [self.contentView addSubview:self.descLable];
        [self.contentView addSubview:self.picUrlImageView];
        [self.picUrlImageView addSubview:self.listenCountLable];
        [self.picUrlImageView addSubview:self.SONLabel];
        [self.picUrlImageView addSubview:self.listenButton];
        
        [_SONLabel release];
        [_listenCountLable release];
        [_picUrlImageView release];
        
    }
    return self;
}
- (void)layoutSubviews {
    [super layoutSubviews];
    self.picUrlImageView.frame = CGRectMake(0, 0, self.bounds.size.width, self.bounds.size.width);
    self.descLable.frame = CGRectMake(0, self.picUrlImageView.bounds.size.height, self.bounds.size.width, 42);
    self.descLable.textAlignment = NSTextAlignmentLeft;
    
    self.listenButton.frame = CGRectMake(self.picUrlImageView.bounds.size.width - 50, 5, 15, 15);
    self.listenCountLable.frame = CGRectMake(self.picUrlImageView.bounds.size.width - 30, 5, 30, 15);
    
    
    self.listenCountLable.textColor = [UIColor whiteColor];
    self.SONLabel.frame = CGRectMake(5, self.picUrlImageView.bounds.size.height - 21, self.picUrlImageView.bounds.size.width / 3, 21);
    self.SONLabel.textColor = [UIColor whiteColor];
}

- (void)setSecModel:(XCSecDataModel *)secModel {
    if (_secModel != secModel) {
        [_secModel release];
        _secModel = [secModel retain];
    }
    [self.picUrlImageView sd_setImageWithURL:[NSURL URLWithString:secModel.picUrl]placeholderImage:[UIImage imageNamed:@"Image-p"]];
    self.descLable.text = secModel.name;
    
    if (secModel.listenCount) {
        if (secModel.listenCount.intValue > 10000) {
            float a = secModel.listenCount.floatValue / 10000;
            self.listenCountLable.text = [NSString stringWithFormat:@"%.1f万", a];
        } else {
            self.listenCountLable.text = [NSString stringWithFormat:@"%@", secModel.listenCount];
        }
    }

}


@end
